package com.ruoyi.web.wx.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.consult.domain.Consult;
import com.ruoyi.consult.service.IConsultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@Api(tags = "咨询")
@RestController
@RequestMapping("wx/consult")
public class WxConsultController extends BaseController {

    @Autowired
    private IConsultService consultService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation("查询所有咨询列表")
    @GetMapping("/list")
    public AjaxResult list(Consult consult) {
        startPage();
        return AjaxResult.success(getDataTable(consultService.selectConsultList(consult)));
    }

    @ApiOperation("查询咨询详情")
    @GetMapping("/findConsultById/{id}")
    public AjaxResult findConsultById(@PathVariable Long id)
    {
        return AjaxResult.success(consultService.selectConsultById(id));
    }


    /**
     * 根据标题模糊查询
     * @param title
     * @return
     */
    @ApiOperation("根据标题模糊查询咨询")
    @GetMapping("getConsultLikeTitle/{title}")
    public AjaxResult getConsultLikeTitle(@PathVariable String title)
    {
        return AjaxResult.success(consultService.getConsultLikeTitle(title));
    }
}
